package cn.wolfcode.shop.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.dubbo.config.annotation.Service;

import cn.wolfcode.shop.domain.SkuProperty;
import cn.wolfcode.shop.mapper.SkuPropertyMapper;
import cn.wolfcode.shop.service.ISkuPropertyService;

@Service
@Transactional
public class SkuPropertyServiceImpl implements ISkuPropertyService {

	@Autowired
	private SkuPropertyMapper propertyMapper;

	@Override
	public List<SkuProperty> getCatalogProperty(Long catalogId) {

		return propertyMapper.getCatalogProperty(catalogId);
	}

	@Override
	public void saveOrUpdate(SkuProperty entity) {

		if (entity.getId() == null) {
			propertyMapper.insert(entity);
		} else {
			propertyMapper.updateByPrimaryKey(entity);
		}
	}

	@Override
	public void delete(Long id) {
		propertyMapper.deleteByPrimaryKey(id);
	}

	@Override
	public SkuProperty getById(Long skuPropertyId) {
		return propertyMapper.selectByPrimaryKey(skuPropertyId);
	}

}
